package chapter3.lessons.conversionPart;

import java.io.*;

/**
 * @Project ：learn_java
 * @File ：conversionStreamDemo01.java
 * @IDE ：IntelliJ IDEA
 * @Author ：自由如风间
 * @Date ：2025/3/1 11:19
 * @Description ：io转换流的应用
 */

public class conversionStreamDemo01 {
    public static void main(String[] args) throws IOException {
        OutputStreamWriter osw = new OutputStreamWriter(new
                FileOutputStream("G:/codes/learn_java/IOTestOutputFiles/test.txt"), "GBK");

        osw.write("char指针数组是字面量，不可修改");
        osw.close();

        InputStreamReader isr = new InputStreamReader(new
                FileInputStream("G:/codes/learn_java/IOTestOutputFiles/test.txt"), "GBK");

        // 创建一个字符缓冲区，用于高效读取字符
        BufferedReader br = new BufferedReader(isr);
        String line;
        // 逐行读取文件内容
        while ((line = br.readLine()) != null) {
            System.out.println(line);
        }
        // 关闭资源
        br.close();
        isr.close();
    }
}
